package leecode

import "sort"

func maximumProduct(nums []int) int {
	//对数组进行排序
	sort.Ints(nums)
	var (
		result int
		temp   int
	)
	if nums[0] > 0 {
		result = nums[len(nums)-1] * nums[len(nums)-2] * nums[len(nums)-3]
	} else {
		//获取最小的两个复数的积
		minNum := nums[0] * nums[1]
		temp = minNum * nums[len(nums)-1]
		result = nums[len(nums)-1] * nums[len(nums)-2] * nums[len(nums)-3]
		if temp > result {
			result = temp
		}
	}
	return result
}
